package com.jxwifi.cloud.quickclean.toolkit;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.idroid.utils.NoDoubleClickListener;
import com.jxwifi.cloud.quickclean.R;
import com.jxwifi.cloud.quickclean.app.AccountMgr;
import com.jxwifi.cloud.quickclean.app.ClientBasicActivity;
import com.jxwifi.cloud.quickclean.app.PasswordLogin;
import com.jxwifi.cloud.quickclean.utils.TitleClient;
import com.jxwifi.cloud.quickclean.utils.ToastUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

public class LogisticsActivity extends ClientBasicActivity implements LogisticsView{


    @Bind(R.id.tv_logistics_company)
    TextView mTvLogisticsCompany;
    @Bind(R.id.tv_logistics_starts_order)
    TextView mTvLogisticsStartsOrder;
    @Bind(R.id.rv_logistics_list)
    RecyclerView mRvLogisticsList;
    @Bind(R.id.img_logistics_images)
    ImageView mImgLogisticsImages;

    private LogisticsPresenter mPresenter;
    private String mDistributionNo;
    private String TravallingType;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logistics);
        ButterKnife.bind(this);
        openEventBus();
        mDistributionNo = getIntent().getStringExtra("logistics_code");
        TravallingType = getIntent().getStringExtra("travalling_type");
        initHead();
        mPresenter=new LogisticsPresenter(mBaseContext,this);
        mPresenter.initData();
    }

    private void initHead() {
        TitleClient holder = new TitleClient(ButterKnife.findById(this, R.id.lin_client_title));
        holder.defineTitle("查看物流");
        holder.defineLeft(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    public String getDistributionNo() {
        return mDistributionNo;
    }

    @Override
    public void oninitData() {
        PasswordLogin.passwordlogin(mBaseContext, TAG, AccountMgr.gettell(mBaseContext), AccountMgr.getpassword(mBaseContext));
        if (PasswordLogin.mIsLogin) {
            mPresenter.initData();
        }
    }

    @Override
    public String getTravallingType() {
        return TravallingType;
    }

    @Override
    public RecyclerView getRvList() {
        return mRvLogisticsList;
    }

    @Override
    public ImageView getLogisticsImages() {
        return mImgLogisticsImages;
    }

    @Override
    public TextView getStartsOrder() {
        return mTvLogisticsStartsOrder;
    }

    @Override
    public void onFailure(int errorCode, String msg) {
        Toast toast = Toast.makeText(mBaseContext, msg, Toast.LENGTH_SHORT);
        ToastUtils.showMyToast(toast, 3000);
    }

    @Override
    public TextView getLogisticsCompany() {
        return mTvLogisticsCompany;
    }
}
